package main

import (
	"fmt"
	"sync"
	"time"
)

func main() {
	test1()
}

func test1() {
	wg := sync.WaitGroup{}
	wg.Add(2)
	var a, b int
	go func() {
		defer wg.Done()
		fmt.Println(111111111111111111)
		a = 1
	}()
	go func() {
		defer wg.Done()
		time.Sleep(time.Second)
		fmt.Println(2222222222222222222)
		b = 2
	}()
	wg.Wait()

	time.Sleep(2 * time.Second)
	fmt.Println(a, b)
}